/*!
 * jQuery ClassyNotty
 * http://www.class.pm/projects/jquery/classynotty
 *
 * Copyright 2011 - 2013, Class.PM www.class.pm
 * Written by Marius Stanciu - Sergiu <marius@picozu.net>
 * Licensed under the GPL Version 3 license.
 * Version 1.1.0
 *
 */
(function($) {
    $.ClassyNotty = function(settings) {
        var container, notty, title, closeIcon, content;
        settings = $.extend({
            title: undefined,
            content: undefined,
            timeout: 0,
            click: undefined
        }, settings);
        container = $("#nottys");
        if (!container.length) {
            container = $("<div>", {
                id:"nottys"
            }).appendTo(document.body)
        };
        notty = $("<div>");
        notty.addClass("nas-announce-panel");
        
        title = $("<div>");
        title.addClass("panel-title");
        closeIcon = $("<div>", {
            click: function() {
            	notty.delay(100).queue(function() {
                    $(this).clearQueue();
                    $(this).remove();
                })
            }
        });
    	closeIcon.addClass("panel-close");
        
        if (settings.title != undefined) {
        	title.html(settings.title);
        	closeIcon.prependTo(title);
        	title.prependTo(notty);
        }
        else {
            title.html("");
        }
        
        content = $("<div>");
        if (settings.content != undefined) {
        	//content.html(settings.content)
        	content.html("<a href='javascript:void(0);' onclick='resPoponclick();'>" + settings.content + "</a>");
        }
        else {
        	content.html("");
        }
        content.prependTo(notty);
        title.prependTo(notty);
        
        notty.prependTo(container);
        notty.show('fast', 'linear');
        if (settings.timeout) {
            setTimeout(function() {
                notty.delay(300).queue(function() {
                    $(this).clearQueue();
                    $(this).remove();
                })
            }, settings.timeout)
        }
        if (settings.click != undefined) {
            notty.addClass("click");
            notty.click(function(event) {
                var target = $(event.target);
                if (!target.is(".hide")) {
                    settings.click.call(this);
                }
            });
        }
        return this;
    }
})(jQuery);